package com.huihang.core.utils;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class Result<T> {
    private Integer code;   //状态码
    private String message; //返回信息
    private T data;         //返回数据

    public static <T> Result<T> success(T data) {
        return new Result<>(ResultCode.SUCCESS.getCode(),ResultCode.SUCCESS.getMessage(), data);
    }

    public static <T> Result<T> error(int resultCode) {
        return new Result<>(resultCode, ResultCode.getMessageByCode(resultCode), null);
    }
}